import { fetchOptionsType, fetchDataType, SearchType } from "../utils/types";

export async function useIndexDataApi(
  params: object = {},
  options: Partial<fetchOptionsType> = {}
) {
  const { data, error, pending, refresh } = await useGetHttp(
    "indexData",
    "/index",
    params,
    options
  );
  return { data, error, pending, refresh };
}

export async function useLoginApi(
  params: object = {},
  options: Partial<fetchOptionsType> = {}
) {
  const { data, error, pending, refresh } = await usePostHttp(
    "login",
    "/login",
    params,
    options
  );
  return {
    data,
    error,
    pending,
    refresh,
  };
}

export async function useSearchApiData(
  query: Partial<SearchType> = {},
  options: Partial<fetchOptionsType> = {}
) {
  const { data, error, pending, refresh } = await useGetHttp(
    "searchApi",
    "/search",
    query,
    options
  );
  return { data, error, pending, refresh };
}
